using System.Windows.Input;
using CuteConsole.Mvvm;

namespace CuteConsole.ConsoleElements
{
  internal class BoolInput : InputElement<bool>
  {
    private RelayCommand _trueCommand;
    private RelayCommand _falseCommand;

    public BoolInput(string request) 
      : base(request)
    {
    }

    public ICommand TrueCommand
    {
      get
      {
        if (_trueCommand == null)
        {
          _trueCommand = new RelayCommand(param => Done(true));
        }
        return _trueCommand;
      }
    }
    public ICommand FalseCommand
    {
      get
      {
        if (_falseCommand == null)
        {
          _falseCommand = new RelayCommand(param => Done(false));
        }
        return _falseCommand;
      }
    }

    private void Done(bool result)
    {
      Input = result;
      Done();
    }
  }
}